/*
 * SearchFrame.java
 *
 * Created on __DATE__, __TIME__
 */

package com.wdzl.frames;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.JOptionPane;

import com.wdzl.biz.DeptBiz;
import com.wdzl.biz.EmpBiz;
import com.wdzl.dao.DeptDao;
import com.wdzl.entity.ConditionBean;
import com.wdzl.entity.Depart;

/**
 *
 */
public class SearchFrame extends javax.swing.JFrame {

	private MainFrame mf;
	private EmpBiz biz=new EmpBiz();
	private DeptBiz deptBiz = new DeptBiz();
	/** Creates new form SearchFrame */
	public SearchFrame(MainFrame mf) {
		this.mf=mf;
		initComponents();
	}


	private void initComponents() {

		jLabel1 = new javax.swing.JLabel();
		jSeparator1 = new javax.swing.JSeparator();
		jLabel2 = new javax.swing.JLabel();
		jTextField1 = new javax.swing.JTextField();
		jLabel3 = new javax.swing.JLabel();
		ButtonGroup group=new ButtonGroup();
		jRadioButton1 = new javax.swing.JRadioButton();
		jRadioButton2 = new javax.swing.JRadioButton();
		group.add(jRadioButton1);
		group.add(jRadioButton2);
		jLabel4 = new javax.swing.JLabel();
		jComboBox1 = new javax.swing.JComboBox();
		jLabel5 = new javax.swing.JLabel();
		jTextField2 = new javax.swing.JTextField();
		jLabel6 = new javax.swing.JLabel();
		jTextField3 = new javax.swing.JTextField();
		jButton1 = new javax.swing.JButton();
		jButton2 = new javax.swing.JButton();

		setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

		jLabel1.setFont(new java.awt.Font("楷体_GB2312", 1, 24));
		jLabel1.setText("\u5458\u5de5\u67e5\u8be2");

		jLabel2.setText("\u59d3\u540d\uff1a");

		jLabel3.setText("\u6027\u522b\uff1a");

		jRadioButton1.setText("\u7537");

		jRadioButton2.setText("\u5973");

		jLabel4.setText("\u90e8\u95e8\uff1a");
		Object[] objs = deptBiz.getDeaprts().toArray();
		jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(objs));
		jLabel5.setText("\u85aa\u8d44\u8303\u56f4\uff1a");

		jLabel6.setText("~");

		jButton1.setText("\u67e5\u8be2");
		jButton1.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				String name=jTextField1.getText();
				String sex="";
				if(jRadioButton1.isSelected()){
					sex="男";
				}
				if(jRadioButton2.isSelected()){
					sex="女";
				}
				Depart d=(Depart)jComboBox1.getSelectedItem();
				int did=d.getId();
				String salary1=jTextField2.getText();
				try {
					if(!salary1.equals(""))
						Double.parseDouble(salary1);
				} catch (Exception e2) {
					// TODO: handle exception
					JOptionPane.showMessageDialog(null, "开始工资非法！", "错误信息", JOptionPane.ERROR_MESSAGE);
					return;
				}
				String salary2=jTextField3.getText();
				try {
					if(!salary2.equals(""))
						Double.parseDouble(salary2);
				} catch (Exception e2) {
					// TODO: handle exception
					JOptionPane.showMessageDialog(null, "结束工资非法！", "错误信息", JOptionPane.ERROR_MESSAGE);
					return;
				}
				ConditionBean condition=new ConditionBean(did,name,sex,salary1,salary2);
				mf.setCondition(condition);
				mf.setTableValue();
			}
		});
		jButton2.setText("\u53d6\u6d88");
		jButton2.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				SearchFrame.this.setVisible(false);
			}
		});

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout
				.setHorizontalGroup(layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								layout
										.createSequentialGroup()
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING,
																false)
														.addGroup(
																layout
																		.createSequentialGroup()
																		.addGap(
																				117,
																				117,
																				117)
																		.addComponent(
																				jLabel1))
														.addGroup(
																layout
																		.createSequentialGroup()
																		.addGap(
																				81,
																				81,
																				81)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addComponent(
																								jLabel2)
																						.addComponent(
																								jLabel3)
																						.addComponent(
																								jLabel5)
																						.addComponent(
																								jLabel4)
																						.addComponent(
																								jButton1,
																								javax.swing.GroupLayout.Alignment.TRAILING))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.TRAILING)
																						.addComponent(
																								jTextField1,
																								javax.swing.GroupLayout.Alignment.LEADING,
																								javax.swing.GroupLayout.PREFERRED_SIZE,
																								108,
																								javax.swing.GroupLayout.PREFERRED_SIZE)
																						.addGroup(
																								javax.swing.GroupLayout.Alignment.LEADING,
																								layout
																										.createSequentialGroup()
																										.addGroup(
																												layout
																														.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.LEADING)
																														.addComponent(
																																jRadioButton1)
																														.addComponent(
																																jTextField2,
																																javax.swing.GroupLayout.PREFERRED_SIZE,
																																53,
																																javax.swing.GroupLayout.PREFERRED_SIZE))
																										.addGap(
																												10,
																												10,
																												10)
																										.addComponent(
																												jLabel6,
																												javax.swing.GroupLayout.PREFERRED_SIZE,
																												14,
																												javax.swing.GroupLayout.PREFERRED_SIZE)
																										.addPreferredGap(
																												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																										.addGroup(
																												layout
																														.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.LEADING)
																														.addComponent(
																																jTextField3,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																52,
																																Short.MAX_VALUE)
																														.addComponent(
																																jRadioButton2)))
																						.addComponent(
																								jComboBox1,
																								javax.swing.GroupLayout.Alignment.LEADING,
																								javax.swing.GroupLayout.PREFERRED_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.PREFERRED_SIZE)
																						.addComponent(
																								jButton2))
																		.addGap(
																				37,
																				37,
																				37))
														.addGroup(
																layout
																		.createSequentialGroup()
																		.addGap(
																				30,
																				30,
																				30)
																		.addComponent(
																				jSeparator1)))
										.addContainerGap(47, Short.MAX_VALUE)));
		layout
				.setVerticalGroup(layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								layout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(jLabel1)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												jSeparator1,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												10,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addGap(10, 10, 10)
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel2)
														.addComponent(
																jTextField1,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addGap(18, 18, 18)
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel3)
														.addComponent(
																jRadioButton1)
														.addComponent(
																jRadioButton2))
										.addGap(18, 18, 18)
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																jComboBox1,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE)
														.addComponent(jLabel4))
										.addGap(18, 18, 18)
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel5)
														.addComponent(
																jTextField2,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE)
														.addComponent(jLabel6)
														.addComponent(
																jTextField3,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addGap(18, 18, 18)
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jButton1)
														.addComponent(jButton2))
										.addContainerGap(24, Short.MAX_VALUE)));

		pack();
	}
	private javax.swing.JButton jButton1;
	private javax.swing.JButton jButton2;
	private javax.swing.JComboBox jComboBox1;
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLabel jLabel2;
	private javax.swing.JLabel jLabel3;
	private javax.swing.JLabel jLabel4;
	private javax.swing.JLabel jLabel5;
	private javax.swing.JLabel jLabel6;
	private javax.swing.JRadioButton jRadioButton1;
	private javax.swing.JRadioButton jRadioButton2;
	private javax.swing.JSeparator jSeparator1;
	private javax.swing.JTextField jTextField1;
	private javax.swing.JTextField jTextField2;
	private javax.swing.JTextField jTextField3;
	// End of variables declaration//GEN-END:variables

}